import { Component } from 'vue';

export interface FormItem {
  label: string;
  field: string;
  componentName?: string; // 组件类型
  formItemProps?: object; // 透传给子组件的props
  componentProps?: object; // 透传给子组件的props
}

// 定义异步组件的类型
type AsyncComponent = () => Promise<Component>;

// 定义接口 A
export interface ComponentCfg {
  [key: string]: AsyncComponent;
}

// 默认支持的组件
export const createDefaultComponents = () => {
  return {
    input: () =>
      import('@/common/components/standard-table/component/input.vue'),
    secretLevel: () =>
      import('@/common/components/secret-level-info/index.vue'),
  };
};

// 默认支持的组件
export const createDefaultConfig = () => {
  return {
    index: {
      title: '序号',
      dataIndex: 'index',
      key: 'index',
      slotName: 'index',
    },
    secretLevel: {
      title: '秘级',
      dataIndex: 'secretLevel',
      slotName: 'secretLevel',
    },
    operate: {
      title: '操作',
      dataIndex: 'operate',
      slotName: 'operate',
    },
  };
};
